﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" status="Under Construction" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">Mapping properties from view to view model</title>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Mapping properties from view to view model</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Sometimes a view (for example, a user control) contains additional properties besides the DataContext to interact with the view model. By default, it is hard to implement this in an MVVM sccenario, but Catel solves this issue using the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_UI_ViewToViewModelAttribute" styleclass="Normal" style="font-style:normal;" translate="true">ViewToViewModel</link><text styleclass="Normal" translate="true"> attribute. </text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">This attribute automatically keeps track of changes in both the view and the view model and this way, a control can have several properties and still implement MVVM.</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Example implementation</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">[TODO] Write example</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Mapping types</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Catel supports the following mapping types using the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_UI_ViewToViewModelMappingType" styleclass="Normal" translate="true">ViewToViewModelMappingType</link><text styleclass="Normal" translate="true"> enum.</text></para>
    <para styleclass="Normal"><table styleclass="Default" rowcount="6" colcount="2">
      <tr style="vertical-align:top">
        <td style="width:193px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" style="font-weight:bold;" translate="true">Type</text></para>
        </td>
        <td style="width:1025px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" style="font-weight:bold;" translate="true">Description</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:193px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">TwoWayDoNothing</text></para>
        </td>
        <td style="width:1025px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Two way, which means that either the view or the view model will update the values of the other party as soon as they are updated.</text></para>
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">When this value is used, nothing happens when the view model of the view changes. This way, it might be possible that the values of the view and the view model are different. The first one to update next will update the other.</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:193px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">TwoWayViewWins</text></para>
        </td>
        <td style="width:1025px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Two way, which means that either the view or the view model will update the values of the other party as soon as they are updated.</text></para>
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">When this value is used, the value of the view is used when the view model of the view is changed, and is directly transferred to the view model value</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:193px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">TwoWayViewModelWins</text></para>
        </td>
        <td style="width:1025px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Two way, which means that either the view or the view model will update the values of the other party as soon as they are updated.</text></para>
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">When this value is used, the value of the view model is used when the view model of the view is changed, and is directly transferred to the view value.</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:193px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">ViewToViewModel</text></para>
        </td>
        <td style="width:1025px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">The mapping is from the view to the view model only.</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:193px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">ViewModelToView</text></para>
        </td>
        <td style="width:1025px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">The mapping is from the view model to the view only.</text></para>
        </td>
      </tr>
    </table></para>
  </body>
</topic>
